package com.runen.infinitemovement.adapter;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.runen.infinitemovement.R;
import com.runen.infinitemovement.model.entity.PathPathSectionListEntity;
import com.runen.infinitemovement.tool.CommonUtil;

public class RoadTextAdapter extends BaseQuickAdapter<PathPathSectionListEntity, BaseViewHolder> {
    private int position = 0;

    public RoadTextAdapter(Context context) {
        super(R.layout.item_road_text);
    }

    public void checkPosition(int position) {
        this.position = position;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, PathPathSectionListEntity item) {
        TextView textView = helper.getView(R.id.tv_road_name);
        TextView tvChallenge = helper.getView(R.id.tv_challenge);
        LinearLayout llContent = helper.getView(R.id.ll_content);
        textView.setText(item.pathName);
        if (position == helper.getAdapterPosition()) {
            llContent.setBackground(CommonUtil.getDrawable(R.drawable.bg_f63d5b_fa5438_dp8));
            textView.setTextColor(CommonUtil.getColor(R.color.white));
            tvChallenge.setTextColor(CommonUtil.getColor(R.color.white));
        } else {
            llContent.setBackground(CommonUtil.getDrawable(R.drawable.bg_ed3f37_stroke_dp8));
            textView.setTextColor(CommonUtil.getColor(R.color.color_FFED3F37));
            tvChallenge.setTextColor(CommonUtil.getColor(R.color.color_FFED3F37));
        }
        if (item.isChallenge) {
            tvChallenge.setVisibility(View.VISIBLE);
        } else {
            tvChallenge.setVisibility(View.GONE);
        }
    }
}
